<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>question</title>
    
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript">
		function select(){
			var size = document.getElementById("pageSize");
			var selectForm = document.getElementById("selectForm");
			selectForm.action = "${pageContext.request.contextPath}/question/query";
			selectForm.submit();
		}
		
	</script>
  </head>
  	
  <body >
  <a href="${pageContext.request.contextPath}/login/personal">test</a>
    <table >
    	<thead>
    		<th>序号</th>
    		<th>标题</th>
    		<th>内容</th>
    		<th>操作</th>
    	</thead>
    	
    	<tbody>
    		<c:forEach items="${pageBean.list}" varStatus="vs" var="q">
    			<tr>
	    			<td>${vs.count}</td>
	    			<td>${q.title}</<td>
	    			<td>${q.content}</<td>
	    			<td>
		    			<button><a href="${pageContext.request.contextPath}/question/delete.action?question.id=${q.id}">删除</a></button>
		    			<button><a href="${pageContext.request.contextPath}/question/queryone.action?question.id=${q.id}">修改</a></button>
		    			<button><a href="${pageContext.request.contextPath}/question/queryAnswer.action?question.id=${q.id}">答案</a></button>
	    			</td>
    			</tr>
    		</c:forEach>
    		当前页：${pageBean.currentPage}，总页数：${pageBean.totalPage}
    		<c:if test="${pageBean.currentPage!=1 }">
    			<a href="${pageContext.request.contextPath}/question/query?pageBean.currentPage=1">首页</a>
    		</c:if>
    		<c:if test="${pageBean.currentPage==1 }">
    			<a>首页</a>
    		</c:if>
    		<c:if test="${pageBean.hasPrePage}">
    			<a href="${pageContext.request.contextPath}/question/query?pageBean.currentPage=${pageBean.currentPage-1}">上一页</a>
    		</c:if>
    		<c:if test="${pageBean.hasPrePage==false}">
    			<a>上一页</a>
    		</c:if>
    		<c:if test="${pageBean.hasNextPage}">
    			<a href="${pageContext.request.contextPath}/question/query?pageBean.currentPage=${pageBean.currentPage+1}">下一页</a>
    		</c:if>
    		<c:if test="${pageBean.hasNextPage==false}">
    			<a>下一页</a>
    		</c:if>
    		<c:if test="${pageBean.totalPage!=pageBean.currentPage}">
    			<a href="${pageContext.request.contextPath}/question/query?pageBean.currentPage=${pageBean.totalPage}">尾页</a>
    		</c:if>
    		<c:if test="${pageBean.totalPage==pageBean.currentPage}">
    			<a>尾页</a>
    		</c:if>
    		<form action="#" method="post" id="selectForm">
    		<select name="pageBean.everyPage" id="pageSize" onchange="select()">
    			<option value="5"  <c:if test="${pageBean.everyPage eq 5}">selected</c:if>>5</option>
    			<option value="10" <c:if test="${pageBean.everyPage eq 10}">selected</c:if>>10</option>
    			<option value="20" <c:if test="${pageBean.everyPage eq 20}">selected</c:if>>20</option>
    			<option value="30" <c:if test="${pageBean.everyPage eq 30}">selected</c:if>>30</option>
    		</select>
    		</form>
    	</tbody>
    </table>
  </body>
</html>
